﻿using System;
using System.Threading;
using System.Threading.Tasks;

namespace ConsumerTest1
{
    class Program
    {
        static async Task Main(string[] args)
        {
            CancellationTokenSource cts = new CancellationTokenSource();

            //IConsumer consumer = new SubscribeConsumer();
            //await consumer.ExcuteAsync(cts.Token);

            //IConsumer consumer = new AvroSpecificConsumer("http://192.168.3.68:8081", "cusavroschemaserializer");
            //await consumer.ExcuteAsync(cts.Token);

            Console.WriteLine("Input your partition's id:");
            string _ = Console.ReadLine();
            int partition = Convert.ToInt32(_);
            IConsumer consumer = new AvroManualAssignConsumer("http://192.168.3.68:8081", "staticconsumer", partition);
            await consumer.ExcuteAsync(cts.Token);

            //IConsumer consumer = new ManualAssignConsumer();
            //await consumer.ExcuteAsync();

            Console.WriteLine("Hello World!");
            Console.CancelKeyPress += (_, e) => {
                e.Cancel = true; //prevent the process from terminating
                cts.Cancel(); //采用这种方式，让consumer里的程序能进行取消操作
            };
        }
    }
}
